Expand description
Counter with CBC-MAC (CCM): Authenticated Encryption and Associated Data (AEAD) algorithm generic over block ciphers with block size equal to 128 bits as specified in RFC 3610.
§Usage
Simple usage (allocating, no associated data):
ⓘ
use aes::Aes256;
use ccm::{
aead::{Aead, KeyInit, OsRng, generic_array::GenericArray},
consts::{U10, U13},
Ccm,
};
// AES-256-CCM type with tag and nonce size equal to 10 and 13 bytes respectively
pub type Aes256Ccm = Ccm<Aes256, U10, U13>;
let key = Aes256Ccm::generate_key(&mut OsRng);
let cipher = Aes256Ccm::new(&key);
let nonce = GenericArray::from_slice(b"unique nonce."); // 13-bytes; unique per message
let ciphertext = cipher.encrypt(nonce, b"plaintext message".as_ref())?;
let plaintext = cipher.decrypt(nonce, ciphertext.as_ref())?;
assert_eq!(&plaintext, b"plaintext message");
This crate implements traits from the aead
crate and is capable to perfrom
encryption and decryption in-place wihout relying on alloc
.
Re-exports§
pub use aead;
Modules§
- Type aliases for many constants.
Structs§
- CCM instance generic over an underlying block cipher.
- Error type.
Traits§
- Authenticated Encryption with Associated Data (AEAD) algorithm core trait.
- In-place stateless AEAD trait.
- Types which can be initialized from key.
- Types which use key for initialization.
Type Aliases§
- Key used by
KeySizeUser
implementors. - CCM nonces
- CCM tags